ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods






FUNCTION:  InStrRev( )

InStrRev(String, Substring, Start, Compare)

The InStrRev function returns the numeric position of the first occurrence of a specified substring within a specified string when starting from the end (right end) of the string.

An output of zero indicates no match.


There are two mandatory arguments.

String

The String argument is the string in which you will search.


Substring

The Substring argument is the substring you are searching for.

Code:
<% =InStrRev("ABCDE ABCDE", "C") %>

Output:
9

There are two optional arguments.

Start

The optional Start argument is the numeric position, counted from the left, which defines where to start the search for the substring.

In the example the search begins at postion 4, counted from the left, and the search goes from the right to left.

Code:
<% =InStrRev("ABCDE ABCDE", "C", 4) %>

Output:
3

Compare

The optional Compare argument must only use either the constant or value of the COMPARISON CONSTANTS.

CONSTANTVALUEDESCRIPTION
VBBinaryCompare0Binary comparison
VBTextCompare1Text Comparison
VBDataBaseCompare2Compare information inside database

In the example, by using VBBinaryCompare, or 0, for the Compare argument, all upper/lower case differences are obeyed in both the search.

Code:
<% =InStrRev("ABCDE ABCDE", "c", 4, 0) %>

Output:
0

In the example, by using VBTextCompare, or 1, for the Compare argument, all upper/lower case differences are ignored in the search.

Code:
<% =InStrRev("ABCDE ABCDE", "c", 4, VBTextCompare %>

Output:
3